package com.yunyi.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yunyi.dao.UserWithAnnotationsMapper;
import com.yunyi.dao.pro.UserMapper;
import com.yunyi.pojo.User;
import com.yunyi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 实现类
 *
 * @author yunyi
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserWithAnnotationsMapper userWithAnnotationsMapper;

    @Override
    public User getUserWithAnnotationsById(Integer id) {
        return userWithAnnotationsMapper.getUserById(id);
    }

    @Autowired
    private UserMapper userMapper;


    @Override
    public User getUserById(Integer id) {
        return userMapper.getUserById(id);
    }

    @Override
    public List<User> getUserListWithPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<User> list = userMapper.getAllUser();
        return list;
    }

    @Override
    public PageInfo<User> getUserListWithTotalPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<User> list = userMapper.getAllUser();
        PageInfo<User> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

}
